﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ARS.Control.Attributes;
using ARS.PublicTool.WebHelper.WebPage;

namespace ARS.Control.Custom.Entity.Forms
{
    public class DateTimeForm:Form
    {

        protected override void OnPreRender(EventArgs e)
        {
            
            base.OnPreRender(e);
        }

        protected override void RenderContents(System.Web.UI.HtmlTextWriter output)
        {
            base.RenderContents(output);
            Fields.DateTimeField field = base.Field as Fields.DateTimeField;

            //this.Page.ClientScript.RegisterClientScriptResource(typeof(DateTimeForm), ResourcePath.Datepicker.js);
            output.Write(ScriptHelper.GetScriptSrc("/Scripts/datepicker/WdatePicker.js"));

            if (base.Field.Value == null || base.Field.Value.ToString() == "0001/1/1 0:00:00")
            {
                base.Field.Value = DateTime.Now.ToString((base.Field as Fields.DateTimeField).DateTimeFormat);
            }
            else
            {
                base.Field.Value = base.GetInputValue();
            }

            string html = string.Format("<input id=\"{0}\" name=\"{0}\" type=\"text\" value='{1}' onclick = \"WdatePicker({{isShowClear:false,readOnly:true,dateFmt:'{2}'}})\"/ >",this.Field.Html_Control_Name,base.Field.Value,field.DateTimeFormat);
            output.Write(base.GetTrHtml(), html);
            base.RenderContents(output);
        }


    }
}
